﻿using System;
using OneMG.Phoenix.Entity;
using OneMG.Phoenix.Respository;
using IBatisNet.DataMapper;
using OneMG.Phoenix.Kernel.IBatisUtil;
using System.Collections.Generic;
using System.Collections;

namespace OneMG.Phoenix.IBatisRepository
{
    public class RightsRepository : BaseIBatisDao,IRights
    {
        public RightsRepository()
            : base("yihaoke_newMap.Config")
        {

        }
        public System.Int32 AddRights(ERights entity)
        {
			string stmtId = "RightsMap.InsertRights";
			 Object obj = base.SqlMapper.Insert(stmtId, entity);
			 return (System.Int32)obj;
        }
        
		public  ERights GetByRightID (System.Int32 rightID)
        {
			string stmtId = "RightsMap.SelectByRightID";
			return base.SqlMapper.QueryForObject<ERights>(stmtId, rightID);
        }
        
        public  void DeleteByRightID (System.Int32 rightID)
        {
			string stmtId = "RightsMap.DeleteByRightID";
			base.SqlMapper.Update(stmtId, rightID);
        }
        
        public  void UpdateByRightID (ERights entity)
        {
			string stmtId = "RightsMap.UpdateByRightID";
			base.SqlMapper.Update(stmtId, entity);
        }

        public IList<ERights> GetByRightTypeID(System.Int32 rightTypeID)
        {
            Hashtable ht = new Hashtable();
            ht.Add("RightTypeID", rightTypeID);
            string stmtId = "RightsMap.SelectByRightTypeID";
            return base.SqlMapper.QueryForList<ERights>(stmtId, ht);

        }

        public string GetRightNameByUserID(System.Int32 userID)
        {
            string stmtId = "RightsMap.SelectRightNameByUserID";
            return base.SqlMapper.QueryForObject<string>(stmtId, userID);

        }



    }
}

